//
//  DownButton.m
//  CarHome
//
//  Created by 王建男 on 14-9-26.
//  Copyright (c) 2014年 WJN_work@163.com. All rights reserved.
//

#import "DownButton.h"

@implementation DownButton

- (void)dealloc
{
    [_button_table release];
    [_button_praise release];
    [_button_picture release];
    [_button_equipment release];
    [_downView release];
    [changView release];
    
    _button_equipment = nil;
    _button_picture = nil;
    _button_praise = nil;
    _button_table = nil;
    _downView = nil;
    changView = nil;
    
    [super dealloc];
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
        self.backgroundColor = myColor_dark;
        
        [self creatView];
        
    }
    return self;
}

#pragma mark -
#pragma mark 创建下部view  -- 功能button

- (void)creatView
{
    self.button_table = [UIButton buttonWithType:UIButtonTypeCustom];
    [_button_table setFrame:CGRectMake(0, 0, self.frame.size.width / 4, self.frame.size.height)];
    [_button_table setTitle:@"报价" forState:UIControlStateNormal];
    [_button_table setTitleColor:[UIColor whiteColor]forState:UIControlStateNormal];
    [_button_table setTag:0];
    
    [self addSubview:_button_table];
    
    
    self.button_picture = [UIButton buttonWithType:UIButtonTypeCustom];
    [_button_picture setFrame:CGRectMake(_button_table.frame.size.width, 0, _button_table.frame.size.width, _button_table.frame.size.height)];
    [_button_picture setTitle:@"图片" forState:UIControlStateNormal];
    [_button_picture setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_button_picture setTag:1];
    
    [self addSubview:_button_picture];
    
    
    
    self.button_equipment = [UIButton buttonWithType:UIButtonTypeCustom];
    [_button_equipment setFrame:CGRectMake(_button_picture.frame.size.width + _button_picture.frame.origin.x, 0, _button_picture.frame.size.width, _button_picture.frame.size.height)];
    [_button_equipment setTitle:@"配置" forState:UIControlStateNormal];
    [_button_equipment setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_button_equipment setTag:2];
    
    [self addSubview:_button_equipment];
    
    
    self.button_praise = [UIButton buttonWithType:UIButtonTypeCustom];
    [_button_praise setFrame:CGRectMake(_button_equipment.frame.size.width + _button_equipment.frame.origin.x, 0, _button_equipment.frame.size.width, _button_equipment.frame.size.height)];
    [_button_praise setTitle:@"评分" forState:UIControlStateNormal];
    [_button_praise setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_button_praise setTag:3];
    
    [self addSubview:_button_praise];
    
    changView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _button_praise.frame.size.width, 5)];
    changView.backgroundColor = [UIColor redColor];
    
    [self addSubview:changView];
}

- (void)setchangeView:(CGFloat )location
{
    [UIView animateWithDuration:0.3 animations:^{
        [changView setFrame:CGRectMake(location, 0, _button_praise.frame.size.width, 5)];
    }];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
